﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk.Metadata;
using System.ComponentModel;

namespace CRMCustom.Parser
{
    public class ExtendedEntityMetadata : CRMTransaction
    {
        [Browsable(false)]
        public EntityMetadata Metadata;

        [Browsable(false)]
        public List<ExtendedAttributeMetadata> Attributes { get; set; }

        [Browsable(false)]
        public bool HasActivities { get; set; }

        [Browsable(false)]
        public bool HasNotes { get; set; }

        [Browsable(false)]
        public StringAttributeMetadata PrimaryAttribute { get; set; }

        #region Basic Browsable Attributes
        [Browsable(true), Category("Basic")]
        public string SchemaName
        {
            get
            {
                return Metadata.SchemaName;
            }
            set
            {
                Metadata.SchemaName = value;
            }
        }

        [Browsable(true), Category("Basic")]
        public string Description
        {
            get
            {
                return Metadata.Description.LocalizedLabels[0].Label;
            }
            set
            {
                Metadata.Description.LocalizedLabels[0].Label = value;
            }
        }

        [Browsable(true), Description("Display name of attribute"), Category("Basic")]
        public string DisplayName
        {
            get
            {
                return Metadata.DisplayName.LocalizedLabels[0].Label;
            }
            set
            {
                Metadata.DisplayName.LocalizedLabels[0].Label = value;
            }
        }
        #endregion Basic Browsable Attributes

        public bool? SendingEmails { get; set; }
    }
}
